package model;

public class ShowTime 
{
	private int year;
	private int month;
	private int day;
	private int hour;
	private int minute;
	private Cinema cinema;
	private Movie movie;
	
	public ShowTime(int year, int month, int day, int hour, int minute, Cinema cinema, Movie movie)
	{
		this.year = year;
		this.month = month;
		this.day = day;
		this.hour = hour;
		this.minute = minute;
		this.cinema = cinema;
		this.movie = movie;
	}

	public int getYear() 
	{
		return year;
	}

	public void setYear(int year) 
	{
		this.year = year;
	}

	public int getMonth() 
	{
		return month;
	}

	public void setMonth(int month) 
	{
		this.month = month;
	}

	public int getDay() 
	{
		return day;
	}

	public void setDay(int day) 
	{
		this.day = day;
	}

	public int getHour() 
	{
		return hour;
	}

	public void setHour(int hour) 
	{
		this.hour = hour;
	}

	public int getMinute() 
	{
		return minute;
	}

	public void setMinute(int minute) 
	{
		this.minute = minute;
	}

	public Cinema getCinema() 
	{
		return cinema;
	}

	public void setCinema(Cinema cinema) 
	{
		this.cinema = cinema;
	}

	public Movie getMovie() 
	{
		return movie;
	}

	public void setMovie(Movie movie) 
	{
		this.movie = movie;
	}
	
	//- Anders
	public String getDate()
	{
		return String.format("%d / %d - %d", day, month, year);
	}
	
	// - Allan
	public String getTime()
	{
		String formatet = "";
		if(minute < 10) {
			formatet = String.format("%d:0%d", hour, minute);
		}
		else {
			formatet = String.format("%d:%d", hour, minute);
		}
		return formatet;
	}
	
	// - Allan
	public String formateMinute()
	{
		String formatet = "";
		if(minute < 10) {
			formatet = String.format("0%d", minute);
		}
		else {
			formatet = String.format("%d", minute);
		}
		return formatet;
	}

	// - Allan
	public String formateHour()
	{
		String formatet = "";
		if(hour < 10) {
			formatet = String.format("0%d", hour);
		}
		else {
			formatet = String.format("%d", hour);
		}
		return formatet;
	}
	
	// - Allan
	public String formateDay()
	{
		String formatet = "";
		if(day < 10) {
			formatet = String.format("0%d", day);
		}
		else {
			formatet = String.format("%d", day);
		}
		return formatet;
	}
	
	// - Allan
	public String formateMonth()
	{
		String formatet = "";
		if(month < 10) {
			formatet = String.format("0%d", month);
		}
		else {
			formatet = String.format("%d", month);
		}
		return formatet;
	}
	
	/**
	 * 
	 * @param p = parameter
	 * @return
	 */
	public String formatTime(int p)
	{
		String formatet = "";
		if(p < 10) {
			formatet = String.format("0%d", p);
		}
		else {
			formatet = String.format("%d", p);
		}
		
		return formatet;
		
	}
	
	@Override
	public boolean equals(Object obj) {
		boolean result = true;
		try {
			ShowTime otherShowTime = (ShowTime) obj;
			result = year == otherShowTime.getYear() &&
					 month == otherShowTime.getMonth() &&
					 day == otherShowTime.getDay() &&
					 hour == otherShowTime.getHour() &&
					 minute == otherShowTime.getMinute() &&
					 cinema.equals(otherShowTime.getCinema()) &&
					 movie.equals(otherShowTime.getMovie());
		}
		catch(Exception e) {
			result = false;
		}
		
		return result;
	}
	
}
